package com.forest.datachangetracker.context;

import com.forest.datachangetracker.enums.OperationType;
import com.forest.datachangetracker.service.AuditLogService;
import lombok.Data;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.spel.standard.SpelExpressionParser;

/**
 *
 * 数据审计数据上下文.
 *
 * @author forest
 */
@Data
public class AuditContext {

    private OperationType operationType;
    private String targetEntity;
    private String targetId;
    private String operatorId;
    private String operatorName;
    private String tenantId;
    private String clientIp;
    private String methodName;
    private String parameters;
    private String businessKey;
    private String description;
    private String batchId;

    private AuditLogService auditLogService;

    private SpelExpressionParser spelParser;

    private EvaluationContext evaluationContext;

    public AuditContext copy() {
        AuditContext copy = new AuditContext();
        copy.setOperationType(operationType);
        copy.setTargetEntity(targetEntity);
        copy.setTargetId(targetId);
        copy.setOperatorId(operatorId);
        copy.setOperatorName(operatorName);
        copy.setTenantId(tenantId);
        copy.setClientIp(clientIp);
        copy.setMethodName(methodName);
        copy.setParameters(parameters);
        copy.setBusinessKey(businessKey);
        copy.setBatchId(batchId);
        copy.setDescription(description);
        copy.setAuditLogService(auditLogService);
        copy.setSpelParser(spelParser);
        copy.setEvaluationContext(evaluationContext);
        return copy;
    }
}
